Skip to content

[water] promote the duplicate non-unit step verifier#1050

Merged
ftynse merged 3 commits intomainfrom
users/ftynse/non-unit-step
Mar 6, 2026
Merged

[water] promote the duplicate non-unit step verifier#1050
ftynse merged 3 commits intomainfrom
users/ftynse/non-unit-step

Conversation

@ftynse
Copy link
Contributor

@ftynse ftynse commented Mar 5, 2026

Until now, we have only been verifying the absence of a second non-unit
step in index expressions of read and write operations. Do so for every
operation in the trait that attaches the attribute. This is not super-efficient
as it requires looking up the attribute on the same parent from all
operations, but guarantees the check to happen unlike using the attribute
verifier which will not kick in in absence of the hyperparameters attribute
even if we can see a problem. A better, longer-term solution is to
introduce a top-level wave kernel operation where hyperparameters are
mandatory. We can also go for a normal form that will perform a
top-down verification collecting the attributes on the way.

Closes #1013.

Until now, we have only been verifying the absence of a second non-unit
step in index expressions of read and write operations. Do so for every
operation. The check is performed when verifying the hyperparameters
attribute since hyperparameters are likely necessary to evaluate the
step expression. Therefore, the verification will be skipped in absence
of this attribute. This is not ideal, but the alternative is to have
every single verifier look up in the region tree to find the
hyperparameters, which isn't very efficient. A better, longer-term
solution is to introduce a top-level wave kernel operation where
hyperparameters are mandatory.

Closes #1013.

Signed-off-by: Alex Zinenko <git@ozinenko.com>
@ftynse ftynse changed the title [water] verify index expr step/strire are positive [water] promote the duplicate non-unit step verifier Mar 5, 2026
@ftynse ftynse requested review from Copilot and martin-luecke and removed request for Copilot March 5, 2026 12:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR promotes the duplicate non-unit step verifier for index expressions from being specific to read/write operations to applying to all Wave operations with an index attribute. Previously, the multi-step check was embedded in verifyIndexElementsPerThread (called only for read/write/selfIndex ops). Now it's centralized in a new verifyIndexStepsAtMostOneNonUnit function in WaveDialect.cpp, which runs for all ops during the wave.hyperparameters attribute verification.

Changes:

  • New verifyIndexStepsAtMostOneNonUnit function in WaveDialect.cpp checks all ops for multiple non-unit index steps (using hyperparameters). Also improves error messages by reporting the symbolic dimension name instead of its integer index.
  • Removed the inline multi-step check from verifyIndexElementsPerThread in WaveOps.cpp, which also drops the now-unused loop index variable.
  • Tests updated in ops-invalid.mlir and propagate-elements-per-thread.mlir to add hyperparameters where needed, update expected error messages, and add a new test case for wave.register.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
water/lib/Dialect/Wave/IR/WaveDialect.cpp Adds new verifyIndexStepsAtMostOneNonUnit function and invokes it for all ops during hyperparameter attribute verification
water/lib/Dialect/Wave/IR/WaveOps.cpp Removes the duplicated multi-step check from verifyIndexElementsPerThread; replaces enumerate loop with simpler range loop
water/test/Dialect/Wave/ops-invalid.mlir Updates read_index_multi_step and read_index_multi_step_eval tests for new error message format; adds write_index_multi_step_eval test
water/test/Dialect/Wave/propagate-elements-per-thread.mlir Adds @multiple_non_unit_steps test; updates @index_multi_non_unit_step to remove now-unnecessary hyperparameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@martin-luecke martin-luecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

ftynse added 2 commits March 6, 2026 10:34
This is slightly more expensive since we need to look up the
hyperparameters every time, but allows to check more reliably and in
absence of hyperparameters. If this is slow, will revise via analyses
and normal forms.

Signed-off-by: Alex Zinenko <git@ozinenko.com>
Signed-off-by: Alex Zinenko <git@ozinenko.com>
@ftynse
Copy link
Contributor Author

ftynse commented Mar 6, 2026

Flaky igemm test, we should consider disabling it...

@ftynse ftynse merged commit e412b50 into main Mar 6, 2026
16 of 17 checks passed
@ftynse ftynse deleted the users/ftynse/non-unit-step branch March 6, 2026 10:16
xintin pushed a commit that referenced this pull request Mar 6, 2026
Until now, we have only been verifying the absence of a second non-unit
step in index expressions of read and write operations. Do so for every
operation in the trait that attaches the attribute. This is not
super-efficient
as it requires looking up the attribute on the same parent from all
operations, but guarantees the check to happen unlike using the
attribute
verifier which will not kick in in absence of the hyperparameters
attribute
even if we can see a problem. A better, longer-term solution is to
introduce a top-level wave kernel operation where hyperparameters are
mandatory. We can also go for a normal form that will perform a
top-down verification collecting the attributes on the way.

Closes #1013.

---------

Signed-off-by: Alex Zinenko <git@ozinenko.com>
xintin pushed a commit that referenced this pull request Mar 6, 2026
Until now, we have only been verifying the absence of a second non-unit
step in index expressions of read and write operations. Do so for every
operation in the trait that attaches the attribute. This is not
super-efficient
as it requires looking up the attribute on the same parent from all
operations, but guarantees the check to happen unlike using the
attribute
verifier which will not kick in in absence of the hyperparameters
attribute
even if we can see a problem. A better, longer-term solution is to
introduce a top-level wave kernel operation where hyperparameters are
mandatory. We can also go for a normal form that will perform a
top-down verification collecting the attributes on the way.

Closes #1013.

---------

Signed-off-by: Alex Zinenko <git@ozinenko.com>
Signed-off-by: xintin <gaurav.verma@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[water] verify index expressions to have at most one non-unit step

3 participants